<!DOCTYPE html>
<#include "/ftl/header.ftl">
<html>
<head>
    <meta charset="UTF-8">
</head>
<#include "/ftl/menu.ftl">

<script type="text/javascript">
    $(document).ready(function() {
        var totalPage = "${pageInfo.pages}";
        var visiblePages = 10;
        if (totalPage == "") {
            totalPage = 0;
            visiblePages = 0;
        }
        if (totalPage == 0) {
            $("#pager").hide();

        }
        if (totalPage != "" && totalPage <= visiblePages) {
            totalPage = Number(totalPage);
            visiblePages = totalPage;
        }
        var currentPage = "${pageInfo.pageNum}";
        if (currentPage == "") {
            currentPage = 1;
        } else {
            currentPage = Number(currentPage);
        }
        if (totalPage == 0 && currentPage > 0) {
            totalPage = 1;
            currentPage = 1;
        }
        //var pageSize = 20;
        var pageSize = "${pageInfo.pageSize}";

        $('#pager').twbsPagination({
            totalPages: totalPage,
            visiblePages: visiblePages,
            prev: "«",
            next: "»",
            startPage: currentPage,
            version: '1.1',
            onPageClick: function (event, page) {
                if (page == currentPage) {
                    return;
                }
                $("#pageNum").val(page);
                $("#pageSize").val(pageSize);

                $("#formData").submit();
                // alert($(this));
                //$('#page-content').text('Page ' + page);
            }


        });

        $("#btnSearch").on("click", function () {

            $("#formData").submit();

        });
    });
</script>
<script type="text/javascript">
    function update(userId) {

        var phone = $("#phone").val()
        var pageNum = $("#pageNum").val()

        window.location.href = "../order/userUpdate?userId="+userId+"&pageNum="+pageNum+"&phone="+phone;
    }

</script>
<body>
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <ol class="breadcrumb">
                <li><a href="#">会员管理</a></li>
                <li class="active">人员列表</li>
            </ol>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <div class="block">
                <div class="form-row">
                    <div class="col-md-6">
                    </div>
                    <div class="col-md-6">
                        <form id="formData" >
                            <input type="hidden" name="pageSize" id="pageSize"  />
                            <input type="hidden" name="pageNum" id="pageNum" />

                            <div class="form-row">
                                <div class="col-md-6">
                                    <div class="col-md-3">手机号码</div>
                                    <div class="col-md-5">
                                        <input type="text" class="form-control" id="phone" name="phone" value="${phone!}" placeholder="手机号码"/>
                                    </div>
                                </div>
                                <div class="col-md-3">
                                    <div class="col-md-3"></div>
                                    <div>
                                        <@shiro.hasPermission name="product:query">
                                        <button class="btn btn-default btn-clean" id="btnSearch"
                                                type="button" >搜索</button>
                                    </@shiro.hasPermission>
                                </div>
                            </div>
                    </form>
                    </div>
                </div>
            </div>
            <div class="content">
                <table class="table table-bordered table-striped table-hover">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>用户id</th>
                        <th>手机号码</th>
                        <th>是否会员</th>
                        <th>首次访问时间</th>
                        <th>会员开通时间</th>
                        <th>会员到期时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <#if wxuserList??>
                    <#list wxuserList as wxuser>
                    <tr>
                        <input type="hidden" id="userId" name="userId" value="${wxuser.userId}" />
                        <td>${wxuser_index+1}</td>
                        <td>${wxuser.userId}</td>
                        <td>${wxuser.phone!}</td>
                        <td><#if wxuser.level==1>是<#else>否</#if></td>
                        <td>${(wxuser.createDate?string('yyyy-MM-dd'))!}</td>
                        <td>${(wxuser.registerDate?string('yyyy-MM-dd'))!}</td>
                        <td>${(wxuser.expireDate?string('yyyy-MM-dd'))!}</td>
                        <td>
                            <#if (wxuser.level)!=1>
                        <button class="btn btn-default btn-clean"
                                type="button" onclick="update('${wxuser.userId}')">开通会员</button>
                        </#if>
                </tr>
            </#list>
        </#if>
        </tbody>

        </table>

    </div>
</div>

</div>
</div>
<div class="text-center">
    <ul id="pager"></ul>
</div>
</div>
</body>
</html>